#include "avz.h"

using namespace AvZ;

AvZ::PaoOperator feng_pao;
AvZ::PaoOperator ping_di_pao;

void Script()
{
    SetZombies({ZOMBIE,
        POLE_VAULTING_ZOMBIE,
        FOOTBALL_ZOMBIE,
        ZOMBONI,
        JACK_IN_THE_BOX_ZOMBIE,
        POGO_ZOMBIE,
        BUNGEE_ZOMBIE,
        LADDER_ZOMBIE,
        CATAPULT_ZOMBIE,
        GARGANTUAR,
        GIGA_GARGANTUAR});

    SelectCards({
        ICE_SHROOM,
        M_ICE_SHROOM,
        COFFEE_BEAN,
        DOOM_SHROOM,
        CHERRY_BOMB,
        FLOWER_POT,
        UMBRELLA_LEAF,
        SQUASH,
        PUMPKIN,
        JALAPENO,
    });

    SetTime(-599, 1);
    feng_pao.resetPaoList({
        {1, 1},
        {5, 1},
        {2, 2},
    });

    ping_di_pao.resetPaoList({
        {2, 6},
        {4, 6},
        {4, 2},
    });

    Card(FLOWER_POT, {{3, 1}});
    ice_filler.start({{2, 1}, {4, 1}, {3, 1}});
    SetTime(-100, 19);
    ice_filler.resetFillList({{2, 1}, {4, 1}});

    SetTime(-599, 1);
    plant_fixer.start(PUMPKIN);
    plant_fixer.resetFixHp(4000 * 2 / 3);

    SetTime(359 - 373, 1);
    feng_pao.roofPao(2, 9);
    ping_di_pao.roofPao(4, 9);

    SetTime(168, 1);
    Card(FLOWER_POT, 1, 8);
    SetTime(326, 2);
    SetTime(326, 2);
    Card({{FLOWER_POT, 5, 9}, {CHERRY_BOMB, 5, 9}});
    SetTime(359 - 100 - 198);
    Card({{DOOM_SHROOM, 1, 8}, {COFFEE_BEAN, 1, 8}});

    SetTime(359 - 100 - 198, 7);
    Card({{FLOWER_POT, 2, 8}, {DOOM_SHROOM, 2, 8}, {COFFEE_BEAN, 2, 8}});

    SetTime(953, 14);
    Card(JALAPENO, 3, 1);
    SetTime(1053 + 20);
    Card({{FLOWER_POT, 3, 9}, {CHERRY_BOMB, 3, 9}});
    SetTime(359 - 100 - 198, 15);
    Card({{DOOM_SHROOM, 3, 9}, {COFFEE_BEAN, 3, 9}});

    for (auto wave : {3, 8, 11, 16}) {
        // PP 641
        SetTime(441 - 387, wave);
        feng_pao.roofPao(2, 9);
        ping_di_pao.roofPao(4, 9);
        SetTime(642 - 100 - 198);
        ice_filler.coffee();
    }

    for (auto wave : {4, 5, 12, 13, 17, 18}) {
        // I-PP(下波预判冰) 1253
        SetTime(1053 - 387, wave);
        feng_pao.roofPao(2, 9);
        ping_di_pao.roofPao(4, 9);
        SetTime(1254 - 100 - 198);
        ice_filler.coffee();
    }

    for (auto wave : {6, 14}) {
        // I-PP 1253
        SetTime(1053 - 387, wave);
        feng_pao.roofPao(2, 9);
        ping_di_pao.roofPao(4, 9);
    }

    SetTime(1048 - 387, 9);
    feng_pao.roofPao(2, 9);
    ping_di_pao.roofPao(4, 9);
    feng_pao.recoverPao({{2, 9}, {4, 9}});
    ping_di_pao.recoverPao({{4, 9}, {2, 9}});
    SetTime(1248 * 2 - 200);
    Card({{FLOWER_POT, 3, 8}, {CHERRY_BOMB, 3, 8}});
    Delay(1524);
    Card(DOOM_SHROOM, 3, 8);
    SetTime(0);
    Card({{FLOWER_POT, 3, 2}, {UMBRELLA_LEAF, 3, 2}});
    SetTime(1053);

    SetTime(394 - 198 - 100, 10);
    Card(COFFEE_BEAN, 3, 8);
    SetTime(317);
    Card({{FLOWER_POT, 1, 9}, {SQUASH, 1, 9}});

    SetTime(1048 - 387, 19);
    feng_pao.roofPao(2, 9);
    ping_di_pao.roofPao(4, 9);
    feng_pao.recoverPao({{1, 9}, {5, 9}});
    ping_di_pao.recoverPao({{5, 9}, {1, 9}});
    SetTime(3648 - 300);
    Card({{FLOWER_POT, 3, 7}, {CHERRY_BOMB, 3, 7}});
    Delay(101);
    Shovel(3, 7);
    KeyConnect('N', [=]() {
        Card({{FLOWER_POT, 4, 8}, {DOOM_SHROOM, 4, 8}});
    });

    SetTime(394 - 387, 20);
    feng_pao.roofPao(2, 7);
    ping_di_pao.roofPao(4, 7);
    SetTime(317);
    Card({{FLOWER_POT, 4, 9}, {SQUASH, 4, 9}});
    SetTime(1053 - 100);
    Card(COFFEE_BEAN, 4, 8);
    SetTime(1053 - 387);
    feng_pao.recoverPao({{2, 9}, {1, 9}});
    ping_di_pao.recoverPao({{4, 9}, {5, 9}});
    SetTime(-200);
    ice_filler.coffee();
    SetTime(600);
    Shovel({{3, 1}, {3, 2}, {3, 2}});
    KeyConnect('A', [=]() {
        Card({{FLOWER_POT, 3, 7}, {CHERRY_BOMB, 3, 7}});
    });
}